package com.sanmu.factory;

import com.sanmu.bean.House;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @version 1.0
 * @Author xinnian
 * @Date 2024/9/14 14:23
 * @注释
 * @create: 2024-09-14 14:23
 */

public class MyBeanPostProcessor implements BeanPostProcessor {


    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization方法执行了" + "bean ："+ bean  + " beanName：" + beanName);
        if (bean instanceof House){
            House house = (House) bean;
            house.setName("叁木树屋");
        }
        return bean;
    }
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization方法执行了" + "bean ："+ bean  + " beanName：" + beanName);
        return bean;
    }
}
